var lockDivCss = {
    "background-color":"#666",
    "display":"none",
    "width":"100%",
    "height":"100%",
    "left":"0",
    "top":"0",  /*FF IE7*/
    "filter":"alpha(opacity=50)",  /*IE*/
    "opacity":"0.5",  /*FF*/
    "z-index":"6",
    "position":"fixed"
}

function lockDiv(){
	var div = document.getElementById("lockDiv20100803");
	var iframe = document.getElementById("lockIframe2011422151437");
    if(! div){
    	$(document.body).append("<div id='lockDiv20100803'></div>");
    }
    div = $("#lockDiv20100803");
	div.css(lockDivCss);
	if(!iframe){
		$(document.body).append("<iframe frameborder='1'  id='lockIframe2011422151437' src='" + appServer + "/view/manage/vc.html' scrolling='no' marginheight='0' marginwidth='0' style='top:0px; left:0px;display:none;position: absolute;z-index: 2;filter:alpha(opacity=0);'></iframe>");
	}
	iframe = $("#lockIframe2011422151437");
	if(isIE6()){
		var fn = function(){
			var h = document.documentElement.clientHeight,
   	         w = document.documentElement.clientWidth,
   	         l = document.documentElement.scrollLeft,
   	         t = document.documentElement.scrollTop;
   	         h += "px";
   	         w += "px";
   	         l += "px";
   	         t += "px";
		     div.css({'position': 'absolute', 'width': w, 'height': h, 'top': t, 'left': l});
		     iframe.css({'position': 'absolute', 'width': w, 'height': h, 'top': t, 'left': l});
		};
		fn();
		window.scrollTo(0, 0);
		window.onscroll = function(){
			fn();
		};
	}
	div.show();
	iframe.css({'width': div.width(), 'height': div.height()});
	iframe.show();
}

function unlockDiv(){
	window.onscroll = null;
	$("#lockDiv20100803").hide();
	$("#lockIframe2011422151437").hide();
}

function isIE6(){
	return $.browser.msie && $.browser.version == 6;
}

function position(event){
	var left = event.pageX ? event.pageX : event.clientX + document.documentElement.scrollLeft;
	var top =  event.pageY ? event.pageY : event.clientY + document.documentElement.scrollTop;
	return {'left': left, 'top': top};
}


/**
 * 弹出层
 * @param div_id
 */
function popupDiv(div_id) {
	lockDiv();
	var div_obj = $("#"+div_id);
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = div_obj.height();
	var popupWidth = div_obj.width();
	//添加并显示遮罩层
	//$("<div id='mask'></div>").addClass("mask")
	//.width(windowWidth * 0.99)
	//.height(windowHeight * 0.99)
	//.click(function() {hideDiv(div_id); })
	//.appendTo("body")
	//.fadeIn(200);
	div_obj.css({"position": "absolute"})
	.animate({left: windowWidth/2-popupWidth/2,
	top: windowHeight/2-popupHeight/2, opacity: "show" }, "slow");
}


/**
 * 隐藏层
 * @param div_id
 */
function hideDiv(div_id) {
	unlockDiv();
	//$("#mask").remove();
	$("#" + div_id).animate({left: 0, top: 0, opacity: "hide" }, "slow");
}